const { execSync } = require('child_process')
const path = require('path')

const protoDir = path.join(__dirname, '../src/protos')
const outputDir = protoDir

const protos = [
  'blog.proto',
  'problem.proto',
  'user.proto',
  'home.proto',
  'chat.proto'
]

protos.forEach(proto => {
  try {
    execSync(`protoc --js_out=import_style=commonjs,binary:${outputDir} --proto_path ${protoDir} ${proto}`)
    console.log(`Successfully compiled ${proto}`)
  } catch (error) {
    console.error(`Failed to compile ${proto}:`, error.message)
  }
})
